package com.jiyinit.web.core.common.constant;

import com.jiyinit.web.core.common.listener.SessionListener;

import javax.servlet.http.HttpSession;
import java.util.Enumeration;

/**
 * Created by lr on 2017/11/24.
 */
public class ForceLogoutUtils {
    public static void forceUserLogout(String username)
    {
        if(SessionListener.sessionMap.get( username ) != null)
        {
            HttpSession session = SessionListener.sessionMap.get( username );

            SessionListener.sessionMap.remove( username );

            Enumeration e = session.getAttributeNames();

            while(e.hasMoreElements())
            {
                String sessionName = (String) e.nextElement();

                session.removeAttribute( sessionName );
            }

            session.invalidate();
        }
    }
}
